import { Alova } from '@/utils/http/alova/index';
import { Config } from '../config';
import type { ForbiddenFreq } from '../config';

export interface RfConfig {
  dataEncryptionMode: number;
  dataEncryptionKey: string;
  meshName: string;
  freqMode: string;
  span: number;
  freqDefault: number;
  freqList: number[];
  forbiddenFreqBands: ForbiddenFreq[];
  pwAtten1: number;
  pwAtten2: number;
  rfDisable: number;
}

export interface TransferConfig {
  dataTransferMode: number;
  linkSnrThreshold: number;
  maxMcformat: number;
  minTF: number;
}

//获取射频参数
export function getRfConfig() {
  return Alova.Get<Config>('/config', {
    meta: {
      isReturnNativeResponse: true, // 关键配置, 返回原生响应头
    },
  });
}

// 更新射频参数
export function updateRfConfig(data: RfConfig) {
  return Alova.Post<string>('/config', data, {
    meta: {
      isReturnNativeResponse: true, // 关键配置, 返回原生响应头
    },
  });
}

// 更新传输配置
export function updateTransferConfig(data) {
  return Alova.Post<string>('/config', data, {
    meta: {
      isReturnNativeResponse: true, // 关键配置, 返回原生响应头
    },
  });
}
